
use axum::response::{IntoResponse, Response};
use http::{header, StatusCode};
use axum::extract::{Multipart, Path as AxumPath, Query, State};
use serde::Deserialize;
use log::info;
use crate::config::address;
use crate::models::AppState::AppState;
#[derive(Deserialize, Debug)]
pub struct DeleteFileRequest{
    id: u64,
}
pub async fn delete_file(State(state):State<AppState>,Query(file_id):Query<DeleteFileRequest>) -> impl IntoResponse {
    // 1. 使用 ID 查询对应的 MD5
    let id = file_id.id;
    println!("{}", id);
    let mut file_databases = state.file_database.clone();
    let mut file = file_databases.lock().await;
    let md5 = file.id_md5.get(&id).cloned();
    if let Some(md5) = md5{
        file.data.get_mut(&md5).unwrap().info.clear();
        }
    AppState::write_file_data_to_json_idmd5(&file.id_md5).await;
    AppState::write_file_data_to_json_file(&file.data).await;
    (StatusCode::OK,).into_response()
    }
